package com.zb.sannuo.account.service.impl;

import com.zb.sannuo.account.dao.AccountAddMapper;
import com.zb.sannuo.account.service.AccountAddService;
import com.zb.sannuo.common.domain.vo.AccountVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class AccountAddServiceImpl implements AccountAddService {

    @Resource
    private AccountAddMapper accountAddMapper;

    @Transactional(timeout = 5)
    @Override
    public boolean addAccount(AccountVo vo) {
        int i = accountAddMapper.addUserLogin(vo);
        Integer userId = vo.getUserId();
        System.out.println(vo.getRoleId());
        int a = accountAddMapper.addUserRole(userId, vo.getRoleId());
        int b = accountAddMapper.addUserStore(userId, vo.getStoreId());
        boolean isOk = false;
        if (i+a+b == 3){
            isOk = true;
        }
        return isOk;
    }
}
